package com.xoms.admin.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xoms.admin.controller.res.bean.RAuditBreakageBean;
import com.xoms.admin.controller.res.bean.RAuditCheckBean;
import com.xoms.admin.controller.res.bean.RAuditPurchaseBean;
import com.xoms.admin.controller.res.bean.RAuditPureBackBean;
import com.xoms.admin.controller.res.bean.RAuditStockInBean;
import com.xoms.admin.controller.res.bean.RProAuditBean;
import com.xoms.admin.controller.res.bean.RProBreakageInfoBean;
import com.xoms.admin.controller.res.bean.RProCheckProInfoBean;
import com.xoms.admin.controller.res.bean.RProPureBackInfoBean;
import com.xoms.admin.controller.res.bean.RProStockInInfoBean;
import com.xoms.admin.controller.res.bean.RPurchaseInfoBean;
import com.xoms.admin.model.AccountBean;
import com.xoms.admin.model.ProAuditBean;
import com.xoms.admin.model.ProBreakageBean;
import com.xoms.admin.model.ProBreakageDetailBean;
import com.xoms.admin.model.ProCheckBean;
import com.xoms.admin.model.ProCheckProInfoBean;
import com.xoms.admin.model.ProPureBackBean;
import com.xoms.admin.model.ProPureBackInfoBean;
import com.xoms.admin.model.ProStockBean;
import com.xoms.admin.model.ProStockInBean;
import com.xoms.admin.model.ProStockInDetailBean;
import com.xoms.admin.model.PurchaseBean;
import com.xoms.admin.model.PurchaseDetailBean;
import com.xoms.admin.model.vo.AuditBreakageBean;
import com.xoms.admin.model.vo.AuditCheckBean;
import com.xoms.admin.model.vo.AuditPureBackBean;
import com.xoms.admin.model.vo.AuditPurechaseBean;
import com.xoms.admin.model.vo.AuditStockInBean;
import com.xoms.admin.model.vo.BatchPurchaseBean;
import com.xoms.admin.model.vo.ProBreakageVo;
import com.xoms.admin.model.vo.ProPureBackVo;
import com.xoms.admin.model.vo.ProStockInVo;
import com.xoms.admin.persist.dao.ProAuditDao;
import com.xoms.admin.persist.dao.ProBreakageDao;
import com.xoms.admin.persist.dao.ProCheckDao;
import com.xoms.admin.persist.dao.ProPureBackDao;
import com.xoms.admin.persist.dao.ProStockDao;
import com.xoms.admin.persist.dao.ProStockInDao;
import com.xoms.admin.persist.dao.PurchaseDao;
import com.xoms.admin.service.ProAuditService;
import com.xoms.admin.service.exception.ServiceException;
import com.xoms.admin.service.res.PageResult;
import com.xoms.util.ArithUtil;
import com.xoms.util.DateTimeUtil;

/**
 * 商品审核实现层
 * 
 * @author chengl
 *
 */
@Service
public class ProAuditServiceImpl implements ProAuditService {

	Logger logger = Logger.getLogger(this.getClass());

	@Autowired
	ProAuditDao proAuditImpl;

	@Autowired
	PurchaseDao purchaseImpl;

	@Autowired
	ProStockInDao proStockInImpl;

	@Autowired
	ProBreakageDao proBreakageImpl;
	
	@Autowired
	ProCheckDao proCheckImpl;

	@Autowired
	ProStockDao proStockImpl;

	@Autowired
	ProPureBackDao proPureBackImpl;

	@Override
	public PageResult<RProAuditBean> getProAudits(AccountBean account, int type, int page, int pageSize,
			String startTime, String endTime) {
		return getProAudits(type, page, pageSize, startTime, endTime, null);
	}

	@Override
	public PageResult<RProAuditBean> getProAudits4Acc(AccountBean account, int type, int page, int pageSize,
			String startTime, String endTime) {
		// 获取提交人的审核列表
		return getProAudits(type, page, pageSize, startTime, endTime, account.getAccid());
	}

	/**
	 * 获取审核列表
	 * 
	 * @param type
	 * @param page
	 * @param pageSize
	 * @param startTime
	 * @param endTime
	 * @param accid
	 * @return
	 */
	private PageResult<RProAuditBean> getProAudits(int type, int page, int pageSize, String startTime,
			String endTime, String accid) {
		PageResult<RProAuditBean> result = new PageResult<RProAuditBean>();
		List<RProAuditBean> resList = new ArrayList<RProAuditBean>();

		// 查询审核数量
		int count = proAuditImpl.selectCount(type, startTime, endTime, accid);
		// 查询审核列表
		if (count > 0) {
			List<ProAuditBean> lists = proAuditImpl.selectList(type, page, pageSize, startTime, endTime, accid);
			if (lists != null) {
				RProAuditBean pa = null;
				for (ProAuditBean a : lists) {
					pa = new RProAuditBean();
					pa = parse(a);
					resList.add(pa);
				}
			}
		}
		result.setData(resList);
		result.setCount(count);
		return result;
	}

	/**
	 * 格式化数据
	 * 
	 * @param au
	 * @return
	 */
	private RProAuditBean parse(ProAuditBean au) {
		RProAuditBean res = new RProAuditBean();
		res.setAid(au.getAid());
		res.setAuditer(au.getAuditer());
		res.setAuditerId(au.getAuditId());
		res.setAuditNo(au.getAuditNo());
		res.setReview(au.getReview());
		res.setStatus(au.getStatus());
		res.setSubmiter(au.getSubmiter());
		res.setSubmiterId(au.getSubmitId());
		res.setTargetId(au.getTargetId());
		res.setType(au.getType());
		res.setSubmitTime(DateTimeUtil.formatTimestamp(au.getSubmitTime()));
		res.setAuditTime(DateTimeUtil.formatTimestamp(au.getAuditTime()));
		return res;
	}

	@Transactional(rollbackFor = Exception.class) // 事务
	@Override
	public boolean audit(AccountBean account, String aid, int status, String remark) {
		boolean flag = false;
		ProAuditBean audit = proAuditImpl.selectOneById(aid);
		if (audit == null) {
			throw new ServiceException("object_is_not_exist", "审核单");
		}
		int hisStatus = audit.getStatus();
		if (hisStatus != 0) {
			throw new ServiceException("audit_status_error");
		}
		// 1更新审核订单状态
		audit.setStatus(status);
		audit.setReview(remark);
		audit.setAuditId(account.getAccid());
		flag = proAuditImpl.update(audit) > 0;
		if (!flag) {
			throw new ServiceException("database_update_fail", "审核状态");
		}
		// 2根据审核结果做操作
		int type = audit.getType();
		String targetId = audit.getTargetId();
		switch (type) {
		case 1: // 采购审核
			PurchaseBean purchase = purchaseImpl.selectOneById(targetId);
			if (purchase == null) {// 采购单不存在
				throw new ServiceException("object_is_not_exist", "采购单");
			}
			flag = purchaseImpl.updateSubmitStatus(targetId, status == 1 ? 3 : 4) > 0;// 3，审核成功4审核失败
			if (!flag) {// 更新状态失败
				throw new ServiceException("database_update_fail", "采购审核状态");
			}
			break;
		case 2: // 入库审核，如果审核成功，1调整库存数量，2重新计算库存成本价格
			ProStockInBean stockIn = proStockInImpl.selectOneById(targetId);
			if (stockIn == null) {// 入库不存在
				throw new ServiceException("object_is_not_exist", "入库单");
			}
			flag = proStockInImpl.updateSubmitStatus(targetId, status == 1 ? 3 : 4) > 0;// 更新入库状态,1提交待审核
			if (!flag) {// 更新状态失败
				throw new ServiceException("database_update_fail", "入库审核状态");
			}
			if (status == 1) {
				// 根据入库单商品数量更新仓库数量
				// 根据商品的成本计算方式计算成本
				// 查询当前入库商品列表
				List<ProStockInVo> lists = proStockInImpl.selectProductListByIds(targetId);
				List<ProStockBean> newStocks = new ArrayList<>();
				if (lists != null) {
					ProStockBean ps = null;
					for (ProStockInVo stock : lists) {
						ps = new ProStockBean();
						ps.setProductId(stock.getProductId());
						ps.setStoreHouseId(stock.getStoreHouseId());
						double newCost = getCost(stock);
						ps.setCost(newCost);
						ps.setStore(stock.getStore() + stock.getStockInNumber());
						ps.setAccountId(account.getAccid());
						newStocks.add(ps);
					}
					// 批量更新
					flag = proStockImpl.replaceStocks(newStocks) > 0;
					if (!flag) {// 更新状态失败
						throw new ServiceException("database_update_fail", "库存");
					}
				}
			}
			break;
		case 3: // 盘库审核
			ProCheckBean check = proCheckImpl.selectOneById(targetId);
			if (check == null) {// 盘库单不存在
				throw new ServiceException("object_is_not_exist", "盘库");
			}
			flag = proCheckImpl.updateSubmitStatus(targetId, status == 1 ? 3 : 4) > 0;// 3，审核成功4审核失败
			if (!flag) {// 更新状态失败
				throw new ServiceException("database_update_fail", "盘库审核状态");
			}
			break;
			
		case 4: // 报损审核
			ProBreakageBean breakage = proBreakageImpl.selectOneById(targetId);
			if (breakage == null) {// 报损单不存在
				throw new ServiceException("object_is_not_exist", "报损单");
			}
			flag = proBreakageImpl.updateSubmitStatus(targetId, status == 1 ? 3 : 4) > 0;// 3，审核成功4审核失败
			if (!flag) {// 更新状态失败
				throw new ServiceException("database_update_fail", "报损审核状态");
			}
			if (status == 1) {//报损审核成功后，更新报损库里对应商品数量
				List<ProBreakageVo> lists = proBreakageImpl.selectProductListByBid(targetId);
				List<ProStockBean> newStocks = new ArrayList<>();
				if (lists != null) {
					ProStockBean ps = null;
					for (ProBreakageVo stock : lists) {
						if(stock.getBreakageNumber() > stock.getStore()) { 
							throw new ServiceException("breakage_number_over_error");
						}
						ps = new ProStockBean();
						ps.setProductId(stock.getProductId());
						ps.setStoreHouseId(stock.getStoreHouseId());
						double newCost = getCost(stock);// 获取新成本
						ps.setCost(newCost);
						ps.setStore(stock.getStore() - stock.getBreakageNumber());// 库存数量减去报损数量
						ps.setAccountId(account.getAccid());
						newStocks.add(ps);
					}
					// 批量更新
					flag = proStockImpl.replaceStocks(newStocks) > 0;
					if (!flag) {// 更新状态失败
						throw new ServiceException("database_update_fail", "库存");
					}
				}
				
			}
			break;
			
		case 5: // 退货审核
			ProPureBackBean pureBack = proPureBackImpl.selectOneById(targetId);
			if (pureBack == null) {// 盘库单不存在
				throw new ServiceException("object_is_not_exist", "退货");
			}
			flag = proPureBackImpl.updateSubmitStatus(targetId, status == 1 ? 3 : 4) > 0;// 3，审核成功4审核失败
			if (!flag) {// 更新状态失败
				throw new ServiceException("database_update_fail", "退货审核状态");
			}
			if (status == 1) {//报损成功后，更新采购单内对应商品数量
				List<ProPureBackVo> lists = proPureBackImpl.selectProductListByPid(targetId);
				List<BatchPurchaseBean> batch = new ArrayList<>();
				if (lists != null) {
					BatchPurchaseBean ps = null;
					for (ProPureBackVo pback : lists) {
						if(pback.getNumber() > pback.getPurNumber()) { 
							throw new ServiceException("purchase_number_over_error");
						}
						ps = new BatchPurchaseBean();
						ps.setPurchaseId(pback.getPurechaseId());
						ps.setProductId(pback.getProductId());
						ps.setNumber(pback.getPurNumber() - pback.getNumber());
						ps.setPrice(pback.getPrice());
						ps.setStaleTime(pback.getStaleTime());
						batch.add(ps);
					}
					// 批量更新
					flag = purchaseImpl.replaceBatchDetail(batch) > 0;
					if (!flag) {
						throw new ServiceException("database_insert_fail","采购订单详情");
					}
					if (!flag) {// 更新状态失败
						throw new ServiceException("database_update_fail", "库存");
					}
				}
				
			}
			break;	
		default:
			break;
		}
		return flag;
	}

	private double getCost(ProBreakageVo stock) {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * 计算成本,加权平均
	 * @param stock
	 * @return
	 */
	private double getCost(ProStockInVo stock) {
		Double oCost = stock.getCost();
		Double stockInCost = stock.getStockInPrice();
		int oNumber = stock.getStore();
		int stockInNumber = stock.getStockInNumber();
		
		Double oTotalCost = ArithUtil.mul(oCost, oNumber);
		Double stockInTotalCost = ArithUtil.mul(stockInCost, stockInNumber);
		Double totalCost = ArithUtil.add(oTotalCost, stockInTotalCost);// 求总金额
		Double cost = ArithUtil.div(totalCost, oNumber+stockInNumber, 4);
		return cost;
	}

	@Override
	public RAuditPurchaseBean getPurchase(AccountBean account, String aid) {
		// 获取审核详情
		AuditPurechaseBean audit = purchaseImpl.selectAuditPureDetailsById(aid);
		if(audit == null) {
			throw new ServiceException("object_is_not_exist","审核采购单");
		}
		return parsePurchase(audit);
	}
	
	/**
	 * 格式化数据
	 * @param audit
	 * @return
	 */
	private RAuditPurchaseBean parsePurchase(AuditPurechaseBean audit) {
		RAuditPurchaseBean res = new RAuditPurchaseBean();
		res.setPurchaseId(audit.getPid());
		res.setPurchaseNo(audit.getPurchaseNo());
		res.setStoreHouse(audit.getStoreHouse());
		res.setStoreHouseId(audit.getStoreHouseId());
		res.setBatch(audit.getBatch());
		res.setRemark(audit.getRemark());
		res.setTotalCost(audit.getTotalCost());
		res.setProvider(audit.getProvider());
		res.setAuditNo(audit.getAuditNo());
		res.setAuditer(audit.getAuditer());
		res.setAuditerId(audit.getAuditerId());
		res.setStatus(audit.getAuditStatus());
		res.setReview(audit.getReview());
		res.setSubmiter(audit.getAccount());
		res.setSubmiterId(audit.getAccountId());
		res.setSubmitTime(DateTimeUtil.formatTimestamp(audit.getCreateTime()));
		res.setAuditTime(DateTimeUtil.formatTimestamp(audit.getAuditTime()));
		List<PurchaseDetailBean> list = audit.getDetails();
		List<RPurchaseInfoBean> reslist = new ArrayList<>(); 
		if(list != null) {
			RPurchaseInfoBean rp = null;
			for(PurchaseDetailBean pd : list ) {
				rp = new RPurchaseInfoBean();
				rp = parsePureDetail(pd);
				reslist.add(rp);
			}
			res.setDetails(reslist);
		}
		
		return res;
	}
	
	/**
	 * 格式化预订详情信息
	 * @param pur
	 * @return
	 */
	private RPurchaseInfoBean parsePureDetail(PurchaseDetailBean pur) {
		RPurchaseInfoBean result = new RPurchaseInfoBean();
		result.setPureNumber(pur.getNumber());
		result.setProduct(pur.getProduct());
		result.setProductId(pur.getProductId());
		result.setCategory(pur.getCategory());
		result.setPrice(pur.getPrice());
		result.setPurchaseId(pur.getPurchaseId());
		result.setStaleTime(pur.getStaleTime());
		result.setProductBar(pur.getProductBar());
		result.setUnit(pur.getUnit());
		return result;
	}

	@Override
	public RAuditStockInBean getStockIn(AccountBean account, String aid) {
		// 获取审核详情
		AuditStockInBean audit = proStockInImpl.selectAuditStockInDetailsById(aid);
		if(audit == null) {
			throw new ServiceException("object_is_not_exist","审核入库");
		}
		return parseStockIn(audit);
	}

	private RAuditStockInBean parseStockIn(AuditStockInBean audit) {
		RAuditStockInBean res = new RAuditStockInBean();
		res.setStoreHouse(audit.getStoreHouse());
		res.setStoreHouseId(audit.getStoreHouseId());
		res.setStockInNo(audit.getStockInNo());
		res.setRemark(audit.getRemark());
		res.setTotalCost(audit.getTotalCost());
		res.setAuditNo(audit.getAuditNo());
		res.setAuditer(audit.getAuditer());
		res.setAuditerId(audit.getAuditerId());
		res.setStatus(audit.getAuditStatus());
		res.setReview(audit.getReview());
		res.setSubmiter(audit.getAccount());
		res.setSubmiterId(audit.getAccountId());
		res.setSubmitTime(DateTimeUtil.formatTimestamp(audit.getCreateTime()));
		res.setAuditTime(DateTimeUtil.formatTimestamp(audit.getAuditTime()));
		List<ProStockInDetailBean> list = audit.getDetails();
		List<RProStockInInfoBean> reslist = new ArrayList<>(); 
		if(list != null) {
			RProStockInInfoBean rp = null;
			for(ProStockInDetailBean pd : list ) {
				rp = new RProStockInInfoBean();
				rp = parseStockDetail(pd);
				reslist.add(rp);
			}
			res.setDetails(reslist);
		}
		
		return res;
	}
	
	private RProStockInInfoBean parseStockDetail(ProStockInDetailBean stock) {
		RProStockInInfoBean result = new RProStockInInfoBean();
		result.setUnit(stock.getUnit());
		result.setProduct(stock.getProduct());
		result.setProductId(stock.getProductId());
		result.setCategory(stock.getCategory());
		result.setPrice(stock.getPrice());
		result.setStaleTime(stock.getStaleTime());
		result.setProductBar(stock.getProductBar());
		result.setNumber(stock.getNumber());
		result.setPureNumber(stock.getPureNumber());
		result.setStockInId(stock.getStockInId());
		result.setStockInNo(stock.getStockInNo());
		result.setCreateTime(DateTimeUtil.formatTimestamp(stock.getCreateTime()));
		return result;
	}

	@Override
	public RAuditBreakageBean getBreakage(AccountBean account, String aid) {
		// 获取审核详情
		AuditBreakageBean audit = proBreakageImpl.selectAuditBreakagesById(aid);
		if(audit == null) {
			throw new ServiceException("object_is_not_exist","审核报损");
		}
		return parseBreakage(audit);
	}

	private RAuditBreakageBean parseBreakage(AuditBreakageBean audit) {
		RAuditBreakageBean res = new RAuditBreakageBean();
		
		res.setStoreHouse(audit.getStoreHouse());
		res.setStoreHouseId(audit.getStoreHouseId());
		res.setBreakageNo(audit.getBreakageNo());
		res.setBid(audit.getBid());
		res.setRemark(audit.getRemark());
		res.setAuditNo(audit.getAuditNo());
		res.setAuditer(audit.getAuditer());
		res.setAuditerId(audit.getAuditerId());
		res.setStatus(audit.getAuditStatus());
		res.setReview(audit.getReview());
		res.setSubmiter(audit.getAccount());
		res.setSubmiterId(audit.getAccountId());
		res.setSubmitTime(DateTimeUtil.formatTimestamp(audit.getCreateTime()));
		res.setAuditTime(DateTimeUtil.formatTimestamp(audit.getAuditTime()));
		List<ProBreakageDetailBean> list = audit.getDetails();
		List<RProBreakageInfoBean> reslist = new ArrayList<>(); 
		if(list != null) {
			RProBreakageInfoBean rp = null;
			for(ProBreakageDetailBean pd : list ) {
				rp = new RProBreakageInfoBean();
				rp = parseStockDetail(pd);
				reslist.add(rp);
			}
			res.setDetails(reslist);
		}
		
		return res;
	}
	
	/**
	 * 格式化详情
	 * @param pur
	 * @return
	 */
	private RProBreakageInfoBean parseStockDetail(ProBreakageDetailBean br) {
		RProBreakageInfoBean res = new RProBreakageInfoBean();
		res.setBreakageId(br.getBreakageId());
		res.setBreakageNo(br.getBreakageNo());
		res.setCategory(br.getCategory());
		res.setNumber(br.getNumber());
		res.setPrice(br.getPrice());
		res.setProduct(br.getProduct());
		res.setProductBar(br.getProductBar());
		res.setProductId(br.getProductId());
		res.setUnit(br.getUnit());
		return res;
	}

	@Override
	public RAuditCheckBean getCheck(AccountBean account, String aid) {
		// 获取审核详情
		AuditCheckBean audit = proCheckImpl.selectAuditCheckDetailsById(aid);
		if(audit == null) {
			throw new ServiceException("object_is_not_exist","审核盘库");
		}
		return parseCheck(audit);
	}

	private RAuditCheckBean parseCheck(AuditCheckBean audit) {
		RAuditCheckBean res = new RAuditCheckBean();
		res.setStoreHouse(audit.getStoreHouse());
		res.setStoreHouseId(audit.getStoreHouseId());
		res.setCheckNo(audit.getCheckNo());
		res.setCid(audit.getCid());
		res.setRemark(audit.getRemark());
		res.setAuditNo(audit.getAuditNo());
		res.setAuditer(audit.getAuditer());
		res.setAuditerId(audit.getAuditerId());
		res.setStatus(audit.getAuditStatus());
		res.setReview(audit.getReview());
		res.setSubmiter(audit.getAccount());
		res.setSubmiterId(audit.getAccountId());
		res.setSubmitTime(DateTimeUtil.formatTimestamp(audit.getCreateTime()));
		res.setAuditTime(DateTimeUtil.formatTimestamp(audit.getAuditTime()));
		List<ProCheckProInfoBean> list = audit.getDetails();
		List<RProCheckProInfoBean> reslist = new ArrayList<>(); 
		if(list != null) {
			RProCheckProInfoBean rp = null;
			for(ProCheckProInfoBean pd : list ) {
				rp = new RProCheckProInfoBean();
				rp = parseCheckDetail(pd);
				reslist.add(rp);
			}
			res.setDetails(reslist);
		}
		
		return res;
	}
	
	/**
	 * 格式化详情
	 * @param check
	 * @return
	 */
	private RProCheckProInfoBean parseCheckDetail(ProCheckProInfoBean check) {
		RProCheckProInfoBean res = new RProCheckProInfoBean();
		res.setCategory(check.getCategory());
		res.setCheckId(check.getCheckId());
		res.setNumber(check.getNumber());
		res.setPrice(check.getPrice());
		res.setProduct(check.getProduct());
		res.setProductId(check.getProductId());
		res.setProductBar(check.getProductBar());
		res.setStoreNumber(check.getStoreNumber());
		res.setUnit(check.getUnit());
		return res;
	}


	@Override
	public RAuditPureBackBean getPureBack(AccountBean account, String aid) {
		// 获取审核详情
		AuditPureBackBean audit = proPureBackImpl.selectAuditPureBacksById(aid);
		if(audit == null) {
			throw new ServiceException("object_is_not_exist","审核退货");
		}
		return parsePureBack(audit);
	}

	private RAuditPureBackBean parsePureBack(AuditPureBackBean audit) {
		RAuditPureBackBean res = new RAuditPureBackBean();
		res.setPid(audit.getPid());
		res.setStoreHouse(audit.getStoreHouse());
		res.setStoreHouseId(audit.getStoreHouseId());
		res.setPurchaseId(audit.getPurchaseId());
		res.setPurchaseNo(audit.getPurchaseNo());
		res.setPureBackNo(audit.getPureBackNo());
		res.setRemark(audit.getRemark());
		res.setAuditNo(audit.getAuditNo());
		res.setAuditer(audit.getAuditer());
		res.setAuditerId(audit.getAuditerId());
		res.setStatus(audit.getAuditStatus());
		res.setReview(audit.getReview());
		res.setSubmiter(audit.getAccount());
		res.setSubmiterId(audit.getAccountId());
		res.setSubmitTime(DateTimeUtil.formatTimestamp(audit.getCreateTime()));
		res.setAuditTime(DateTimeUtil.formatTimestamp(audit.getAuditTime()));
		List<ProPureBackInfoBean> list = audit.getDetails();
		List<RProPureBackInfoBean> reslist = new ArrayList<>(); 
		if(list != null) {
			RProPureBackInfoBean rp = null;
			for(ProPureBackInfoBean pd : list ) {
				rp = new RProPureBackInfoBean();
				rp = parsePureBackDetail(pd);
				reslist.add(rp);
			}
			res.setDetails(reslist);
		}
		return res;
	}
	
	/**
	 * 格式化详情
	 * @param pur
	 * @return
	 */
	private RProPureBackInfoBean parsePureBackDetail(ProPureBackInfoBean br) {
		RProPureBackInfoBean res = new RProPureBackInfoBean();
		res.setCategory(br.getCategory());
		res.setNumber(br.getNumber());
		res.setPrice(br.getPrice());
		res.setProduct(br.getProduct());
		res.setProductBar(br.getProductBar());
		res.setProductId(br.getProductId());
		res.setUnit(br.getUnit());
		res.setPureBackId(br.getPureBackId());
		return res;
	}

}
